//结束时记录新的最好成绩
function onNewScore(score) {
    score > best && (best = score, window.localStorage.setItem(keyStorage, best));

    //todo
    //step1:当前得分 score， 和 历史最高 best 都发送到数据库记录

    //step2:根据数据库的系统判断值 system_value 和 score 值，进行 娱乐奖的判断
    //娱乐奖的接口：http://www.xiaoyaoji.cn/doc/3GyT1LNieD
    //score >= system_value 进行增加娱乐奖的值
    //score < system_value 进行减少娱乐奖的值
}

//加载游戏结束场景
var GameoverNormal = function (a, b, c, d) {
    //step1:结束时记录新的最好成绩
    onNewScore(Math.abs(score));

    //step2:创建容器
    var e = new createjs.Container;
    d.addChild(e);

    //step3:游戏结束图片
    a = new createjs.Bitmap(queue.getResult("gameoverbg"));
    e.addChild(a);

    //step4:游戏结束文字图片
    a = new createjs.Bitmap(queue.getResult("gameover"));
    a.setAnchorPoint(0.5, 0.5);
    a.x = 320;
    a.y = 190;
    e.addChild(a);

    //step5:当前得分文字
    a = new createjs.Bitmap(queue.getResult("curscore"));
    a.x = 90;
    a.y = 290;
    e.addChild(a);
    a = Math.abs(score); //绝对值
    a = new createjs.Text(a.toString(), "bold 60px Arial", b); //创建文本
    a.textBaseline = "middle"; //居中
    a.x = 370;
    a.y = 320;
    e.addChild(a);

    //step6:历史最高图片
    a = new createjs.Bitmap(queue.getResult("maxscore"));
    a.x = 90;
    a.y = 390;
    e.addChild(a);
    a = Math.abs(best);
    b = new createjs.Text(a.toString(), "bold 60px Arial", b);
    b.textBaseline = "middle";
    b.x = 370;
    b.y = 420;
    e.addChild(b);

    //step7:点击开始播放
    b = new createjs.Bitmap(queue.getResult("playbtn"));
    b.setAnchorPoint(0.5, 0.5);
    b.x = 185;
    b.y = 560;
    e.addChild(b);
    //step7-1:播放按下操作
    b.on("mousedown", function (a) {
        IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95);
    }, b);
    //step7-2:播放按下起来操作
    b.on("pressup", function (a) {
        this.scaleY = this.scaleX = 1;
        score = 0;
        c();
        d.removeChild(e);
    }, b);

    //step8:历史记录
    b = new createjs.Bitmap(queue.getResult("topbtn"));
    b.setAnchorPoint(0.5, 0.5);
    b.x = 455;
    b.y = 560;
    e.addChild(b);
    //step8-1:历史记录按下操作
    b.on("mousedown", function (a) {
        IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95);
    }, b);
    //step8-1:历史记录按下起来操作
    b.on("pressup", function (a) {
        this.scaleY = this.scaleX = 1;
        goHome();
    }, b);

    //step9:分享
    // b = new createjs.Bitmap(queue.getResult("sharebtn"));
    // b.setAnchorPoint(0.5, 0.5);
    // b.x = 320;
    // b.y = 700;
    // e.addChild(b);
    //step9-1:分享按下操作
    // b.on("mousedown", function (a) {
    //     IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95);
    // }, b);
    //step9-1:分享按下起来操作
    // b.on("pressup", function (a) {
    //     this.scaleY = this.scaleX = 1;
    //     dp_share();
    // }, b);
};
